package com.demoworld;

import com.demoworld.daos.BankDao;
import com.demoworld.entities.tbBank;
import com.google.gson.GsonBuilder;
import org.junit.Test;

import java.util.UUID;

/**
 * Created by francis on 2017/6/14.
 */
public class main {
    private BankDao dao = new BankDao();

    @Test
    public void getById() {
        tbBank tmp = dao.getById("ec104c1b-c84c-4079-8803-a79acab986c2");
        dao.close();
        System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(tmp));
    }

@Test
public void add() {
    tbBank tmp = new tbBank();
    tmp.setBalance(Double.parseDouble(System.currentTimeMillis() % 10000 + "." + System.currentTimeMillis() % 56000));
    tmp.setUserid(UUID.randomUUID().toString());
    tmp.setUsername("francis");
    dao.add(tmp);
    dao.close();
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(tmp));
}

    @Test
    public void update() {
        tbBank tmp = dao.getById("b6797254-8833-470d-82b1-b49507e2b944");
        tmp.setUsername("francis" + System.currentTimeMillis());
        dao.update(tmp);
        dao.close();
        System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(tmp));
    }


}
